jQuery(document).ready(function() {
	function eStore_attach_media_uploader(key) {
		jQuery('#' + key + '_button').click(function() {
			text_element = jQuery('#' + key).attr('name');
			button_element = jQuery('#' + key + '_button').attr('name');
			tb_show('', 'media-upload.php?TB_iframe=1&width=640&height=485');
			return false;
		});		
		window.send_to_editor = function(html) {
			var self_element = text_element;
			imgurl = jQuery(html).attr('href');
			jQuery('#' + self_element).val(imgurl);
			tb_remove();
		};
	}
	eStore_attach_media_uploader('producturl');
	eStore_attach_media_uploader('productthumb');
	eStore_attach_media_uploader('buttonimageurl');	
});